package kr.co.boogui.service;

import javax.servlet.http.HttpServletRequest;

import kr.co.boogui.dao.MovieDAO;
import kr.co.boogui.dao.NewsDAO;

public class MainChartService {
	public static void mainChartOrder(HttpServletRequest req) {
		//String action = "../main.jsp";
		
		int order = 0;
		String orderStr = req.getParameter("order");
		if ( orderStr != null){
			order = Integer.parseInt(req.getParameter("order"));
		} else {
			order = 0;
		}		
		req.setAttribute("newslist", NewsDAO.readMainNews("1"));
		req.setAttribute("interviewlist", NewsDAO.readMainNews("2"));
		req.setAttribute("reviewlist", NewsDAO.readMainNews("3"));
		req.setAttribute("newsimg", NewsDAO.readMainNewsImg("1"));
		req.setAttribute("interviewimg", NewsDAO.readMainNewsImg("2"));
		req.setAttribute("reviewimg", NewsDAO.readMainNewsImg("3"));
		switch (order) {
			case 1:				
				req.setAttribute("moviechart", MovieDAO.selectMainMovie("reservationrate"));
				req.setAttribute("chartmn", "예매율 : ");
				req.setAttribute("chartnum", 1);
				req.setAttribute("newslist", NewsDAO.readMainNews("1"));
				req.setAttribute("interviewlist", NewsDAO.readMainNews("2"));
				req.setAttribute("reviewlist", NewsDAO.readMainNews("3"));
				break;
			case 2:
				req.setAttribute("moviechart", MovieDAO.selectMainMovie("playdate"));
				req.setAttribute("chartmn", "개봉일 : ");
				req.setAttribute("chartnum", 3);
				req.setAttribute("newslist", NewsDAO.readMainNews("1"));
				req.setAttribute("interviewlist", NewsDAO.readMainNews("2"));
				req.setAttribute("reviewlist", NewsDAO.readMainNews("3"));
				break;
			case 3:
				req.setAttribute("moviechart", MovieDAO.selectMainMovie("stars"));
				req.setAttribute("chartmn", "평점 : ");
				req.setAttribute("chartnum", 2);
				req.setAttribute("newslist", NewsDAO.readMainNews("1"));
				req.setAttribute("interviewlist", NewsDAO.readMainNews("2"));
				req.setAttribute("reviewlist", NewsDAO.readMainNews("3"));
				break;
			default:
				req.setAttribute("moviechart", MovieDAO.selectMainMovie("reservationrate"));
				req.setAttribute("chartmn", "예매율 : ");
				req.setAttribute("chartnum", 1);
				req.setAttribute("newslist", NewsDAO.readMainNews("1"));
				req.setAttribute("interviewlist", NewsDAO.readMainNews("2"));
				req.setAttribute("reviewlist", NewsDAO.readMainNews("3"));
				break;			
		}
	
		//return action;
	}

}
